//
//  WHYVisitorTableViewController.swift
//  WHYWeibo-1.0
//
//  Created by 王洪运 on 15/11/22.
//  Copyright © 2015年 王洪运. All rights reserved.
//

import UIKit

class WHYVisitorTableViewController: UITableViewController {
    
    private var userLogon = WHYUserAccountViewModel.sharedUserAccount.userLogon
//    private var userLogon = false
    
    var visitorView: WHYVisitorView?
    
    override func loadView() {
        userLogon ? super.loadView() : setupVisitorView()
    }

    private func setupVisitorView() {
        visitorView = WHYVisitorView()
//        visitorView?.delegate = self
        view = visitorView
        
//        设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "clickRegisterButton")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "clickLoginButton")
        
//        设置访客视图里的按钮监听事件
        visitorView?.registerButton.addTarget(self, action: "clickRegisterButton", forControlEvents: .TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "clickLoginButton", forControlEvents: .TouchUpInside)
    }

}

// MARK: - 按钮点击事件
extension WHYVisitorTableViewController {
    @objc func clickRegisterButton() {
        QL2("点击了注册按钮")
    }
    
    @objc func clickLoginButton() {

        let vc = WHYOAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
    }
}


extension WHYVisitorTableViewController {
    
    
    
}



